package com.lqjava.flowable.beans.exceptions;

import com.alibaba.fastjson.JSON;

import java.util.Map;
/**
 * Service
 * 主要功能: 区分登录类型
 * 使用层级: ServiceImpl
 * @author lq 2021年3月21日 18:35:33
 */
public class ServiceException extends RuntimeException{

	private static final long serialVersionUID = -7862119184457005046L;
	
	private Map<String,Object> data;

    /**
     * 自定义错误信息
     * @param message
     */
    public ServiceException(String message) {
        super(message);
    }
    
    public ServiceException(String message,  Map<String, Object> data) {
		super(message);
		this.data = data;
	}

	public Map<String, Object> getData() {
		return data;
	}

	public void setData(Map<String, Object> data) {
		this.data = data;
	}
	public String getBody(){
		String body = null;
		if(this.data != null){
			body = JSON.toJSONString(this.data);
		}
		return body;
	}
    
    public static void throwBusiness(String message){
    	throw new ServiceException(message);
    }
    
    public static void throwBusiness(String message,Map<String, Object> data){
		throw new ServiceException(message,data);
    }

}
